<template>
  <div class="recordCss">
    <div class="titleCss">{{ titleName }}</div>
    <div class="bodyCss">
      <div class="timeCss">
        <div class="timeItemCss">
          <div class="timeNumCss">{{ timeNum }}</div>
          <div>{{ timeName }}</div>
        </div>
      </div>
      <div class="tableCss">
        <el-form :model="formData" ref="queryForm" size="small" label-width="120px">
          <el-form-item label="日期" label-width="120px">
            <el-date-picker v-model="formData.data1" placeholder="请选择"/>
          </el-form-item>
          <div class="formBtnCss">
            <el-button type="primary" @click="searchBtn">查询</el-button>
            <el-button @click="resetBtn">重置</el-button>
          </div>
        </el-form>
        <div class="tableBtnCss">
          <el-button type="primary" @click="exportBtn">导出</el-button>
        </div>
        <el-table
          max-height="400"
          :data="tableData"
          border
          style="width: 100%">
          <el-table-column
            type="index"
            label="序号"
            width="55"
            align="center">
          </el-table-column>
          <el-table-column
            prop="data1"
            label="紫外线灯设备位置名称"
            min-width="150">
          </el-table-column>
          <el-table-column
            prop="data2"
            label="日期"
            min-width="100">
          </el-table-column>
          <el-table-column
            prop="data3"
            label="擦拭状态"
            min-width="100">
            <template #default="scope">
              {{ data3Map[scope.row.data3] }}
            </template>
          </el-table-column>
          <el-table-column
            prop="data4"
            label="擦拭照片"
            min-width="100">
            <template #default="scope">
              <el-image 
                style="width: 50px; height: 50px"
                :src="scope.row.data4[0]" 
                :preview-src-list="scope.row.data4">
              </el-image>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top:10px;text-align: right;"
          :pageSize="pageSize"
          layout="prev, pager, next"
          :page-sizes="[10, 20, 50]"
          :total="total"
          @sizeChange="handleSizeChange"
          @currentChange="handleCurrentChange">
        </el-pagination>
      </div>
    </div>
    <div class="bottomBtnCss">
      <el-button @click="goBackBtn">返回</el-button>
    </div>
  </div>
</template>

<script>
import { getCurrentDay} from '@/utils/business.js'
export default {
  data(){
    return{
      formData:{
        data1:null,
      },
      tableData:[],
      pageSize:10,
      total:1000,
      data3Map:{
        0:'未擦拭',
        1:'已擦拭',
      },
      titleName:null,
      timeName:null,
      timeNum:null,
    }
  },
  mounted(){
    this.getList()
    const titleNameMap = {
      0:'紫外线灯擦拭记录',
      1:'紫外线灯强度检测记录',
      2:'空气消毒机消毒效果检测记录',
      3:'紫外线灯消毒记录',
    }
    const topNameMap = {
      0:'未擦拭次数',
      1:'未强度监测次数',
      2:'未监测次数',
      3:'未消毒次数',
    }
    this.titleName = titleNameMap[this.$route.query.type]
    this.timeName = topNameMap[this.$route.query.type]
    this.timeNum = Math.floor( Math.random() * 999 )
  },
  methods:{
    handleCurrentChange(){
      
    },
    handleSizeChange(){
      
    },
    resetBtn(){

    },
    exportBtn(){

    },
    searchBtn(){
      
    },
    goBackBtn(){
      this.$router.back()
    },
    getList(){
      const random = Math.floor( Math.random() * 10) + 5
      let list = []
      for( let i=0;i<random;i++){
        const random1 = Math.floor( Math.random() * 2) 
        list.push({
          data1: '【测试数据】医院走廊xxx',
          data2: getCurrentDay(),
          data3: random1,
          data4: [
            'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
            'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
            'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
            'https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg',
            'https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg',
            'https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg',
            'https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg'
          ],
        })
      }
      this.tableData = list
    },
  },
}
</script>

<style lang="scss" scoped>
.recordCss{
  overflow: hidden;
  position: relative;
  background-color: #fff;
  padding: 20px;
  border-radius: 10px;
  height: calc( 100vh - 66px - 40px);
  display: flex;
  flex-direction: column;
  .titleCss{
    text-align: center;
    font-size: 24px;
    font-weight: bold;
  }
  .bodyCss{
    margin-top: 20px;
    margin-left: 20px;
    width: calc( 100% - 10px);
    padding-right: 40px;
    overflow-y: auto;
    height: calc( 100% - 90px);
    padding-bottom: 20px;
    .timeCss{
      display: flex;
      .timeItemCss{
        border-radius: 4px;
        border: 2px solid #d8d8d8;
        width: 200px;
        line-height: 34px;
        padding: 10px;
        .timeNumCss{
          font-size: 24px;
        }
      }
    }
    .tableCss{
      padding-bottom: 20px;
      margin-top: 20px;
      .tableBtnCss{
        padding-bottom: 10px;
        margin-top: 8px;
      }
      .el-form{
        display: flex;
        flex-wrap: wrap;
        .formBtnCss{
          margin-left: 20px;
          text-align: center;
        }
      }
    }
  }
  .bottomBtnCss{
    margin-top: auto;
    text-align: right;
  }
}
</style>